function menuFix() {
 var sfEls = document.getElementById("nav").getElementsByTagName("li");
 for (var i=0; i<sfEls.length; i++) {
  sfEls[i].onmouseover=function() {
  this.className+=(this.className.length>0? " ": "") + "sfhover";
  }
  sfEls[i].onMouseDown=function() {
  this.className+=(this.className.length>0? " ": "") + "sfhover";
  }
  sfEls[i].onMouseUp=function() {
  this.className+=(this.className.length>0? " ": "") + "sfhover";
  }
  sfEls[i].onmouseout=function() {
  this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), 
"");
  }
 }
}
window.onload=menuFix;

function siteTabs(){
	   if($('body').width()<479){
	       $('.center_wrapper .inner').addClass('idTabs');
		   $(".idTabs").idTabs();
	   }else{
		   $(".center_wrapper .inner h2 a").unbind();
		   $(".center_wrapper .inner h2 a").removeClass('selected'); 
		   $('.center_wrapper .inner ul').removeAttr("style");
	       $('.center_wrapper .inner').removeClass('idTabs'); 
		   
	   }
}

function siteindthere(){
	var imgheight = $('.ind_three .img img').height();
	$('.ind_three').css('height',imgheight);
}


$(window).resize(function(){
	siteindthere();
	siteTabs();
});















$(function(){
	
	
	
	siteindthere();
    siteTabs();
	
	$('.order_days_select a').click(function(){
		$('.order_days_select a').attr('class','');
		$(this).attr('class','selected');
	});
	
	
	$('.singleProduct_sub').click(function(){
		if($("ul", this).is(":visible")){
			$("ul", this).stop().hide();
		}else{
			$(".singleProduct_sub ul").hide();
		    $("ul", this).stop().show();
		}
	});
	$('.singleProduct_sub .inputlist a').click(function(){
		$(this).parent().parent().parent().find('input').val($(this).html());
		if($(this).parent().parent().parent().find('input').val()>0){
			$(this).parent().parent().parent().find('em').attr('class','selected');
		}else{
			$(this).parent().parent().parent().find('em').removeClass('selected');		
		}
		$("ul", this.parent()).hide();
	});
	
	
	
	
	
	
	//
	var liactive = $('.nav_list .subli').parent();
	liactive.each(function(){
        if($(this).is('.selected')){
		    $(this).find('.arrow').attr('class','arrow_on');
		}else{
			$(this).find('.arrow').attr('class','arrow');
			
		}
	});
	$('.nav_list .subli').click(function(){
		if($(this).find("b").attr('class') == 'arrow_on'){
		   	$(this).find("b").attr('class','arrow');
			$(this).siblings("ul").hide();
			$(this).siblings("ul").attr('display','none');
		}else{
			$(this).find("b").attr('class','arrow_on');
			$(this).siblings("ul").show();
			$(this).siblings("ul").attr('display','block');
		}
	});
	//
	$('.nav .blue_pre').hover(function(){
		$(".info", this).stop().show();
	}, function() {
		$(".info", this).stop().hide();
	});
	//
	$('.recommend_warp').hover(function(){
		$(".recommend_con", this).stop().show();
		$(this).parent().parent().css('background-color','#f7f7f7');
	}, function() {
		$(".recommend_con", this).stop().hide();
		$(this).parent().parent().css('background-color','');
	});
	/*
	$('.fc_con .fc_day').hover(function(){
		$(".info", this).stop().show();
	}, function() {
		$(".info", this).stop().hide();
	});
	*/
	$('.alert .close').click(function(){
	    $(this).parent().hide();
	});
	
	
	
	
});

(function (window, $) {
	//public variables
    PageModel_DESKTOP_MODE = "desktop_mode";
	PageModel_TABLET_MODE = "tablet_mode";
	PageModel_MOBILE_MODE = "mobile_mode";
	

	//static state variables
	NavModule_STATE_EXPANDED = "expanded";
	NavModule_STATE_COLLAPSED = "collapsed";
	
	var _navState = "collapsed";
	var _navButton = $('.juiceUplogo').find("span.menu_open_button");
	var _content = $('#page_modules');
	var _footer = $('#footer_modules');
	var _utilitynav = $('.contentHead');
	var _nav = $('#nav');
	var _pageModel;
	
    
	
	_navButton.on("click",function(){
		if(_navState == NavModule_STATE_EXPANDED){
			onNavCollapse();
		}else{
			onNavExpand();
		}
	});
	
	$(window).resize(function() {
		evalPageState($(window).width());
		onPageModeChange();
	});
	evalPageState($(window).width());
	//constructor function
	
		
	 function onNavExpand(){
		 
		 //_nav.css("z-index",-1);
		 _nav.css("margin-top",0);
		 _nav.css("visibility","visible");
         _content.stop().animate({marginLeft:'150px'},400);
		 _utilitynav.stop().animate({marginLeft:'150px'},400);
		 _footer.stop().animate({marginLeft:'150px'},400,function(){
			   _nav.css("z-index",10);
			 });
		 
         _navState = NavModule_STATE_EXPANDED;
     }
	 function onNavCollapse(){
		 
		 _nav.css("z-index",-1);
		 _content.stop().animate({marginLeft:'0px'},400);
		 _utilitynav.stop().animate({marginLeft:'0px'},400);
		 _footer.stop().animate({marginLeft:'0px'},400);
		 
         _navState = NavModule_STATE_COLLAPSED;
	 }
	 
	 function onNavReset(){
          _footer.removeAttr("style");
          _content.removeAttr("style");
          _utilitynav.removeAttr("style");
          _nav.removeAttr("style");
		  _nav.find("h1").removeAttr("style");
          _navState = NavModule_STATE_COLLAPSED;
     }
     
	 function onPageModeChange(){
		onNavReset();
	 }
	 
	 function setPageMode(mode){
			if(mode == _pagemode) return;
			_pagemode = mode;
	 }
	 
	 $(window).resize(function() {
		evalPageState($(window).width());
		onPageModeChange();
	 });
	 
	 function evalPageState(w){
			if(w <= 991){
				_pageModel = PageModel_TABLET_MODE;
			}
     }
	
}(window, jQuery));


$(document).ready(function(){$(window).scroll(function(){if($(this).scrollTop()>200){$('.go_top').fadeIn(200);}else{$('.go_top').fadeOut(200);}});$('.go_top').click(function(event){event.preventDefault();$('html, body').animate({scrollTop:0},300);})});



/* idTabs ~ Sean Catchpole - Version 2.2 - MIT/GPL */
(function(){var dep={"jQuery":"jquery-latest.min.js"};var init=function(){(function($){$.fn.idTabs=function(){var s={};for(var i=0;i<arguments.length;++i){var a=arguments[i];switch(a.constructor){case Object:$.extend(s,a);break;case Boolean:s.change=a;break;case Number:s.start=a;break;case Function:s.click=a;break;case String:if(a.charAt(0)=='.')s.selected=a;else if(a.charAt(0)=='!')s.event=a;else s.start=a;break;}}
if(typeof s['return']=="function")
s.change=s['return'];return this.each(function(){$.idTabs(this,s);});}
$.idTabs=function(tabs,options){var meta=($.metadata)?$(tabs).metadata():{};var s=$.extend({},$.idTabs.settings,meta,options);if(s.selected.charAt(0)=='.')s.selected=s.selected.substr(1);if(s.event.charAt(0)=='!')s.event=s.event.substr(1);if(s.start==null)s.start=-1;var showId=function(){if($(this).is('.'+s.selected))
return s.change;var id="#"+this.href.split('#')[1];var aList=[];var idList=[];$("a",tabs).each(function(){if(this.href.match(/#/)){aList.push(this);idList.push("#"+this.href.split('#')[1]);}});if(s.click&&!s.click.apply(this,[id,idList,tabs,s]))return s.change;for(i in aList)$(aList[i]).removeClass(s.selected);for(i in idList)$(idList[i]).hide();$(this).addClass(s.selected);$(id).show();return s.change;}
var list=$("a[href*='#']",tabs).unbind(s.event,showId).bind(s.event,showId);list.each(function(){$("#"+this.href.split('#')[1]).hide();});var test=false;if((test=list.filter('.'+s.selected)).length);else if(typeof s.start=="number"&&(test=list.eq(s.start)).length);else if(typeof s.start=="string"&&(test=list.filter("[href*='#"+s.start+"']")).length);if(test){test.removeClass(s.selected);test.trigger(s.event);}
return s;}
$.idTabs.settings={start:0,change:false,click:null,selected:".selected",event:"!click"};$.idTabs.version="2.2";$(function(){$(".idTabs").idTabs();});})(jQuery);}
var check=function(o,s){s=s.split('.');while(o&&s.length)o=o[s.shift()];return o;}
var head=document.getElementsByTagName("head")[0];var add=function(url){var s=document.createElement("script");s.type="text/javascript";s.src=url;head.appendChild(s);}
var s=document.getElementsByTagName('script');var src=s[s.length-1].src;var ok=true;for(d in dep){if(check(this,d))continue;ok=false;add(dep[d]);}if(ok)return init();add(src);})();